package com.example.myapplication;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.TextView;

public class NewsDetailActivity extends AppCompatActivity {
    public static final String EXTRA_NEWS = "extra_news";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news_detail);

        // 从 Intent 中获取新闻对象
        News news = (News) getIntent().getSerializableExtra(EXTRA_NEWS);

        TextView titleView = findViewById(R.id.detail_title);
        TextView authorView = findViewById(R.id.detail_author);
        TextView contentView = findViewById(R.id.detail_content);

        if (news != null) {
            titleView.setText(news.getTitle());
            authorView.setText("作者：" + news.getAuthor());
            contentView.setText(news.getContent());
        }
    }
}